#include <dae.h>
#include <dom/domCOLLADA.h>
#include <modules/daeLIBXMLPlugin.h>
#include <string>
#include <iostream>

#define log std::cout<<__FILE__<<" "<<__LINE__<<":"

int main(int argc,char * argv[])
{
#if 0 // fix file name
	if( argc < 2 )
	{
		std::cout<<"Usage: "<<argv[0]<<" <*.dae> "<<std::endl;
		return 0;
	}
	std::string path;
	path = "file:///";
	path += argv[1];
#endif
	daeString path  = "file:///C:/Dev/engine-dev/ma-engine/media/orignal/pino/models/model.dae";
	DAE *collada_dae = new DAE();
//	daeLIBXMLPlugin ioPlugin(*collada_dae);
//	collada_dae->setIOPlugin(&ioPlugin);
	int iRet = 0;
	iRet = collada_dae->load(path);
//	domCOLLADA *dom = collada_dae.open(path);
	if( DAE_OK != iRet )
	{
		log<<"can not open dae file:["<<path<<"]"<<std::endl;
		return -1;
	}
	daeDatabase *daeDB = collada_dae->getDatabase();
	if( NULL == daeDB )
	{
		log<<"can not open dae database."<<std::endl;
		return -1;
	}
	daeUInt geometryElementCount = daeDB->getElementCount(NULL, "geometry", NULL);
	for( daeUInt currentGeometry = 0;currentGeometry < geometryElementCount;currentGeometry++ )
	{
    		
		daeElement *element = NULL;
		daeDB->getElement(&element,currentGeometry,NULL, "geometry");
		if( NULL == element )
		{
			continue;
		}
		domGeometry *thisGeometry = static_cast<domGeometry *>(element);
		domMesh *thisMesh = thisGeometry->getMesh();
		log<<"currentGeometry:["<<currentGeometry<<"]"<<std::endl;
	}
	collada_dae->unload(path);
	return 0;
}
